x86/mm: don't override an existing shadow memory allocation when
authorKeir Fraser <keir@xen.org>
Fri, 19 Nov 2010 13:20:48 +0000 (13:20 +0000)
committerKeir Fraser <keir@xen.org>
Fri, 19 Nov 2010 13:20:48 +0000 (13:20 +0000)
enabling log-dirty shadows on a PV guest.

Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
xen/arch/x86/mm/shadow/common.c

index 143a2d73d80a58118b4d074a0c379e6baa7c63f9..7a8627c5878e6c00c1247f345bffb9d43b8d8f5b 100644 (file)
@@ -3311,17 +3311,23 @@ static int shadow_one_bit_enable(struct domain *d, u32 mode)
 
     mode |= PG_SH_enable;
 
-    if ( d->arch.paging.mode == 0 )
+    if ( d->arch.paging.shadow.total_pages == 0 )
     {
-        /* Init the shadow memory allocation and the hash table */
-        if ( sh_set_allocation(d, 1, NULL) != 0 
-             || shadow_hash_alloc(d) != 0 )
+        /* Init the shadow memory allocation if the user hasn't done so */
+        if ( sh_set_allocation(d, 1, NULL) != 0 )
         {
             sh_set_allocation(d, 0, NULL);
             return -ENOMEM;
         }
     }
 
+    if ( d->arch.paging.mode == 0 )
+    {
+        /* Init the shadow hash table */
+        if ( shadow_hash_alloc(d) != 0 )
+            return -ENOMEM;
+    }
+
     /* Update the bits */
     sh_new_mode(d, d->arch.paging.mode | mode);